package com.ninechapters.trilobites.newsreader.util
{
	

	public class RESTQuery
	{
		public static const NEWSMANIA_REST_BASE:String = "http://localhost/newsreader/index.php";
		
		public static function createLoginQuery(username:String, password:String):String {
			return NEWSMANIA_REST_BASE + "?" + createParam("RequestType", "Login") + createParam("username", username) + createParam("password", password);
		}
		
		public static function createRegisterQuery(username:String, password:String):String {
			return NEWSMANIA_REST_BASE + "?" + createParam("RequestType", "Register") + createParam("username", username) + createParam("password", password);
		}
		
		public static function createGetNewsSourcesQuery(username:String):String {
			return NEWSMANIA_REST_BASE + "?" + createParam("RequestType", "GetNewsSources") + createParam("username", username);
		}
		
		public static function createAddNewsFeedQuery(username:String, label:String, url:String):String {
			return NEWSMANIA_REST_BASE + "?" + createParam("RequestType", "AddNewsFeed") + createParam("username", username) + createParam("label", label) + createParam("url", url);
		}
		
		public static function createRemoveNewsFeedQuery(username:String, label:String):String {
			return NEWSMANIA_REST_BASE + "?" + createParam("RequestType", "RemoveNewsFeed") + createParam("username", username) + createParam("label", label);
		}
		
		private static function createParam(param:String, value:String):String {
			return "&" + param + "=" +value;
		}
	}
}